/*
 * Player.java
 * 
 * Class to store a hand of cards to a player.			
 */
public class Player {

	private String name;	// Player's name
	private Card[] hand;	// Player's hand of cards
	private int tail;
	
	// Constructor
	public Player(String n, int hand_size){
		name = n;
		hand = new Card[hand_size];
		tail = 0;
	}
	
	// Adds card to the hand
	public void addToHand(Card card){
		hand[tail] = card;
		tail++;
	}
	
	// Prints out the hand
	public void showHand(){
		for(int i = 0; i < hand.length; i++){
			StdOut.println(hand[i].toString());
		}
	}
	
	// Sorts the hand by suit and rank based on the
	// ranking determined in Card.java
	public void sortHand(){
		Card temp;
		int max = 0;
		for(int h = 0; h < hand.length; h++){
			for(int i = h; i < hand.length; i++){
				if(hand[i].showRank()>hand[max].showRank()){
					max = i;
				}
			}
			temp = hand[h];
			hand[h] = hand[max];
			hand[max] = temp;
			max = h + 1;
		}
	}
	
	// Returns the number of cards in the Player's hand
	public int handSize(){
		return hand.length;
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
